import { mapGetters } from 'vuex'

export const commonMixin = {
  data () {
    return {
      sortParams: {},
      currentPage: 1,
      pageSize: 20,
      totalCount: 0
    }
  },
  computed: {
    ...mapGetters([
      'size'
    ])
  },
  created () {
    this.query()
  },
  methods: {
    query () {
      this.currentPage = 1
      this.getPage()
    },
    sortChange (val) {
      this.sortParams = {
        ...(val.order ? {orderByColName: val.prop, isAsc: val.order === 'ascending' ? true : false} : {})
      }
      this.getPage()
    }
  }
}
